package day05;

import java.math.BigDecimal;

public class MyBigDecimal {
    public static void main(String[] args) {
        //求和
        BigDecimal bd1 = new BigDecimal("0.1");
        BigDecimal bd = new BigDecimal("0.3");
        BigDecimal add= bd .add(bd1);
        System.out.println(add);
        //求积
        BigDecimal multiply = bd1.multiply(bd);
        System.out.println(multiply);
        //求商
        BigDecimal divide = bd1.divide(bd, 2, BigDecimal.ROUND_HALF_UP);//四舍五入
        BigDecimal divide1 = bd1.divide(bd, 2, BigDecimal.ROUND_FLOOR);//最后去尾
        BigDecimal divide2 = bd1.divide(bd, 2, BigDecimal.ROUND_UP);//最后一位进一
        System.out.println(divide);System.out.println(divide1);System.out.println(divide2);
//求差
        BigDecimal subtract = bd1.subtract(bd);
        System.out.println(subtract);

    }
}
